#!/bin/awk -f
# Converts dyana constraints to xplor
# todo; make it read aqua input..
{
    av=($4+$5)/2 
    dev=av-$4 
    segi="    "
    
    if ( $3=="PHI") {
        print "assign" 
        print "     (segi \""segi"\" and resi " $1-1 " and name c ) "
        print "     (segi \""segi"\" and resi " $1 " and name n ) "
        print "     (segi \""segi"\" and resi " $1 " and name ca ) "
        print "     (segi \""segi"\" and resi " $1 " and name c ) "
        print "         1 " av " " dev " 2"
    } else if ( $3=="PSI") {
        print "assign" 
        print "     (segi \""segi"\" and resi " $1 " and name n ) "
        print "     (segi \""segi"\" and resi " $1 " and name ca ) "
        print "     (segi \""segi"\" and resi " $1 " and name c ) "
        print "     (segi \""segi"\" and resi " $1+1 " and name n ) "
        print "         1 " av " " dev " 2"
    } else {
        print "ERROR: UNKNOWN ANGLE: " $0
    }
}
